package Homework.game;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class GetScoreAvgN {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num;
        System.out.println("输入评委人数:");
        num = sc.nextInt();
        List<Double> scores = new ArrayList<>();
        for (int i=1;i<=num;i++){
            System.out.println("请输入第"+i+"位评委的评分:");
            scores.add(sc.nextDouble());
        }
        System.out.println(scores);
        System.out.println("平均分为:"+avgScore(scores));

    }

    public static double avgScore(List<Double> scores){
        System.out.println(scores);
        Collections.sort(scores);
        System.out.println(scores);
        double sum=0;
        for (int i=1;i<scores.size()-1;i++){
            sum+=scores.get(i);
        }
        System.out.println(sum);
        double avg=sum/(scores.size()-2);
        return avg;
    }
}
